package com.ruoyi.api.controller;

import com.ruoyi.result.ResultView;
import com.ruoyi.system.domain.EquipmentMaintenance;
import com.ruoyi.system.service.IEquipmentMaintenanceDetailService;
import com.ruoyi.system.service.IEquipmentMaintenanceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Author: lvaitly
 * Time: 15:17
 * Desc: 维保相关
 */
@RestController
@RequestMapping("/api/maintenance")
@Slf4j
public class MaintenanceController {
    @Autowired
    private IEquipmentMaintenanceService equipmentMaintenanceService;
    @Autowired
    private IEquipmentMaintenanceDetailService equipmentMaintenanceDetailService;

    //获取维保记录
    @PostMapping("/list/{type}")
    public ResultView getVehicleMaintenanceList(@PathVariable String type,@RequestBody EquipmentMaintenance o){
        if(null==o.getType()||null==o.getEquipmentInfoId()){
            return ResultView.error(-1,"invalid param ");
        }
        return ResultView.ok(equipmentMaintenanceService.selectEquipmentMaintenanceListByType(o));
    }

    //获取详情
    @PostMapping("/detail/{id}")
    public ResultView getMaintenanceDetail(@PathVariable Long id){
        return ResultView.ok(equipmentMaintenanceDetailService.selectEquipmentMaintenanceDetailByMaintenanceId(id));
    }
}
